local require = require
local ns_mysqlTask  = require("modules.commhm.mysqlTask")
local gg            = require('modules.business_welfare.welfare_gg')
local utils         = require('modules.commhm.utils')
local business_table  = require("modules.business_common.utils.business_table")
local log           = require("modules.commhm.log")

local next = next
local type = type

local FOO = {
    _VERSION = '0.12.1',
    config = {},
    name    = 't_yinxiangcard',
    db_name = 'busines_db',
}



------------------------------------------------------------
--                     业务逻辑表                          --
------------------------------------------------------------
--[[
drop table if exists `t_yinxiangcard`;
create table if not exists `t_yinxiangcard`(
    `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `card_id` varchar(64) not null default '' COMMENT '银享卡ID',
    `card_type` varchar(64) not null default '' COMMENT '银享卡类型',
    `uin` int(20) not null default 0 comment '玩家UIN',
    `rcd_time` timestamp not null default current_timestamp comment '开始记录时间',
    primary key(card_id),
    key `id` (`id`),
    key `card_type` (`card_type`),
    key `uin` (`uin`),
    key `rcd_time` (`rcd_time`)
)engine=innodb AUTO_INCREMENT=1 default charset=utf8;


查看表结构
DESC t_yinxiangcard;
--]]


FOO.insert_record = function( data_)
   --local tmp_data =  business_table.copy(data_)
   local table_name = FOO.name
   local mysql_task_ = ns_mysqlTask:new(table_name, data_)
   local mysql_ = mysql_task_:getInsertSql()
   local res = gg.call_mysql(mysql_, FOO.db_name)
   if res and res.affected_rows and res.affected_rows > 0 then
       return true
   end

   return false
end

FOO.select_record = function(data_, fields_string_, post_fix_ )
    local table_name = FOO.name
	local mysql_task_ = ns_mysqlTask:new( table_name, data_ )
	local mysql_ =  mysql_task_:getSelectSql( fields_string_, post_fix_ )
    local res = gg.call_mysql(mysql_, FOO.db_name)
    return res
end

FOO.update_record = function (data_, post_fix_)
    local table_name = FOO.name
    local mysql_task_ = ns_mysqlTask:new( table_name, data_ )
	local mysql_ = mysql_task_:getUpdateSql( post_fix_ )

    local res = gg.call_mysql(mysql_, FOO.db_name )
	if  res and res.affected_rows and res.affected_rows > 0 then
        return res.affected_rows
	end

	return 0
end

return FOO